# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Contributor: Krassy Boykinov <kboykinov@teamcentrixx.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=evolution-data-server
pkgver=3.50.2
pkgrel=0
pkgdesc="data server for evolution"
options="!check" # Tests fail on the builders, passes CI
url="https://projects.gnome.org/evolution"
arch="all"
license="GPL-2.0-or-later"
depends_dev="
	gcr-dev
	icu-dev
	libgdata-dev
	"
makedepends="$depends_dev
	bison
	boost-dev
	cmake
	flex
	glib-dev
	gnome-online-accounts-dev
	gnu-libiconv-dev
	gobject-introspection-dev
	gperf
	gtk+3.0-dev
	gtk4.0-dev
	json-glib-dev
	krb5-dev
	libcanberra-dev
	libgweather4-dev
	libical-dev
	libphonenumber-dev
	libsecret-dev
	libsoup3-dev
	libxml2-dev
	nss-dev
	openldap-dev
	samurai
	sqlite-dev
	vala
	webkit2gtk-4.1-dev
	webkit2gtk-6.0-dev
	"
checkdepends="db-utils"
subpackages="$pkgname-dev $pkgname-lang"
source="https://download.gnome.org/sources/evolution-data-server/${pkgver%.*}/evolution-data-server-$pkgver.tar.xz"

build() {
	CFLAGS="$CFLAGS -I/usr/include/gnu-libiconv" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DSYSCONF_INSTALL_DIR=/etc \
		-DCMAKE_BUILD_TYPE=None \
		-DENABLE_GOA=ON \
		-DENABLE_INTROSPECTION=ON \
		-DENABLE_VALA_BINDINGS=ON \
		-DWITH_PHONENUMBER=ON \
		-DWITH_LIBDB=OFF \
		-DENABLE_SCHEMAS_COMPILE:BOOL=OFF \
		-DENABLE_OAUTH2_WEBKITGTK4=ON
	cmake --build build
}

check() {
	cd build
	# failing tests on s390x. -locale tests fail due to musl not supporting LC_ADDRESS.
	case "$CARCH" in
		s390x) ;;
		*) CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E "(test-book-cache-cursor-change-locale|test-sqlite-cursor-change-locale)"
	esac
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	rm -rf "$pkgdir"/usr/lib/systemd
}

sha512sums="
9e2a34e06a446ae142535072a3d6916e31b7be987b114c111fb0687fa32a3fe4085ba5a09ccd77fb395d107e5c673130dc770bae74a50fdb566c91cd9de85610  evolution-data-server-3.50.2.tar.xz
"
